package com.wg.web_app.service;

import java.util.ArrayList;
import java.util.List;

import com.google.gson.JsonElement;
import com.wg.web_app.dao.SuperDaoFactory;
import com.wg.web_app.dao.table.*;
import com.wg.web_app.domin.DataBuilder;
import com.wg.web_app.domin.response.*;

public class NumberService {

	public Response<Number> del(int nid) {
		SuperDaoFactory.getUnDao().delete(DataBuilder.tun().nid(nid).build());
		return new Response<Number>(ServiceConstants.STATUS_DELETE_SUCCESS);
	}

	public Response<Number> update(int nid, String tag, String number) {
		SuperDaoFactory.getNumberDao().update(
				DataBuilder.tnumber().id(nid).build(),
				DataBuilder.tnumber().tag(tag).number(number).build()
				);
		return new Response<Number>(ServiceConstants.STATUS_UPDATE_SUCCESS);
	}

	public Response<Number> add(int userid, String detail, String number) {
		int nid = SuperDaoFactory.getNumberDao().insert(DataBuilder.tnumber().number(number).tag(detail).build());
		SuperDaoFactory.getUnDao().insert(DataBuilder.tun().uid(userid).nid(nid).build());
		return new Response<Number>(ServiceConstants.STATUS_INSERT_SUCCESS);
	}
	

}
